<?php
if ( ! defined("IN_OP") )
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
$palygroup=getvar("palygroup");
$open=getvar("open");

$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
require_once( "class_5h/RateConfig_5h.php" );
$RateConfig_5h = new RateConfig_5h($gametype);

if ( $gametype == 24 )
{
	$chkPArr = array ( "r1" => 0 , "rp1" => array ( 1 , 2 ) , "rp3" => array ( 3 , 4 ) , "rp5" => array ( 5 , 6 ) , "rp7" => array ( 7 , 8 ) , "rp9" => array ( 9 , 10 ) );
	$chkPArrStr = array ( "rp1" => array ( "冠军" , "亚军" ) , "rp3" => array ( "季军" , "第四" ) , "rp5" => array ( "第五" , "第六" ) , "rp7" => array ( "第七" , "第八" ) , "rp9" => array ( "第九" , "第十" ) );
	$chkP = $chkPArr[$bettypegroup];
	unset($chkPArr);
	$sql = "SELECT * FROM lotto_{$tbl} WHERE open = '".$open."' AND openbet < '".date("Y-m-d H:i:s")."' AND n1 > 0";
	$rs = getdb($sql);
	if ( ! $rs->eof )
	{
		$i = 0;
		$total = mysql_num_rows($rs->result);
		$ballDataArr = array ( array ( array ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) , array ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ) , array ( $total , $total , $total , $total , $total , $total , $total , $total , $total , $total ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) , array ( ) );
		$nTemp = array ( -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 );
		$a2Idx = array ( -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 );
		$pDataArr = array ( array ( 4 , 1 , 0 ) , array ( 6 , 2 , 0 ) , array ( 8 , 4 , 0 ) , array ( 5 , 1 , 1 ) , array ( 7 , 2 , 1 ) , array ( 9 , 4 , 1 ) );
		$pDataArr2 = array ( array ( 10 , 1 ) , array ( 11 , 2 ) );
		$pL = count($pDataArr);
		$pL2 = count($pDataArr2);
		$maxTotalArr = array ( );
		$maxTotal = 0;
		while ( ! $rs->eof )
		{
			if ( $chkP )
			{
				for ( $index = 0; $index < count($chkP); $index ++  )
				{
					$ballNum = str_pad($rs->f["n".$chkP[$index]] , 2 , "0" , STR_PAD_LEFT);
					$ballNumIdx = $ballNum - 1;
					$ballDataArr[0][$index][$ballNumIdx] ++;
					$index1 = $index + 2;
					if ( $nTemp[$index1] != $ballNum )
					{
						$a2Idx[$index1] ++;
						$ballDataArr[$index1][$a2Idx[$index1]] = "";
					}
					$ballDataArr [$index1][$a2Idx[$index1]] .= $ballNum."<br />";
					$nTemp[$index1] = $ballNum;
				}
				$pArr = array ( str_split($rs->f["p".$chkP[0]] , 1) , str_split($rs->f["p".$chkP[1]] , 1) );
				for ( $j = 0; $j < 6; $j ++  )
				{
					$pIdx0 = $pDataArr[$j][0];
					$pIdx1 = $pDataArr[$j][1] - 1;
					if ( $nTemp[$pIdx0] != $pArr[$pDataArr[$j][2]][$pIdx1] )
					{
						$a2Idx[$pIdx0] ++;
						$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] = "";
					}
					if ( $pDataArr[$j][1] == 4 )
					{
						$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] .= ( $pArr[$pDataArr[$j][2]][$pIdx1]?$RateConfig_5h->getBetContent(6 , $pArr[$pDataArr[$j][2]][$pIdx1] , TRUE)."<br />":"" );
					}
					else
					{
						$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] .= ( $pArr[$pDataArr[$j][2]][$pIdx1]?$RateConfig_5h->getBetContent($pDataArr[$j][1] , $pArr[$pDataArr[$j][2]][$pIdx1] , TRUE)."<br />":"" );
					}
					$nTemp[$pIdx0] = $pArr[$pDataArr[$j][2]][$pIdx1];
				}
			}
			$pArr = str_split($rs->f['p11'] , 1);
			for ( $j = 0; $j < 2; $j ++  )
			{
				$pIdx0 = $pDataArr2[$j][0];
				$pIdx1 = $j;
				if ( $nTemp[$pIdx0] != $pArr[$pIdx1] )
				{
					$a2Idx[$pIdx0] ++;
					$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] = "";
				}
				$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] .= ( $pArr[$pIdx1]?$RateConfig_5h->getBetContent($pDataArr2[$j][1] , $pArr[$pIdx1] , TRUE)."<br />":"" );
				$nTemp[$pIdx0] = $pArr[$pIdx1];
			}
			$i ++;
			$rs->next();
		}
		unset($pArr);
		unset($nTemp);
		unset($a2Idx);
		unset($pDataArr);
		unset($pDataArr2);
		$rs->close();
		unset($rs);
		$maxTotal = 0;
		$maxTotal0 = 0;
		$starI = 9;
		if ( $chkP )
		{
			$ballTblTitle="<tr class=\"title02_3d color5h02\"><th>今天</th><th>01</th><th>02</th><th>03</th><th>04</th><th>05</th><th>06</th><th>07</th><th>08</th><th>09</th><th>10</th></tr>";
			$showChkPStr="<span id=\"chgBV1\" class=\"disClc\">{$chkPArrStr[$bettypegroup][0]}</span><span id=\"chgBV3\" class=\"disClc\">单双</span><span id=\"chgBV5\" class=\"disClc\">大小</span><span id=\"chgBV7\" class=\"disClc\">龙虎</span>&nbsp;&nbsp;<span id=\"chgBV2\" class=\"disClc\">{$chkPArrStr[$bettypegroup][1]}</span><span id=\"chgBV4\" class=\"disClc\">单双</span><span id=\"chgBV6\" class=\"disClc\">大小</span><span id=\"chgBV8\" class=\"disClc\">龙虎</span>&nbsp;&nbsp;";
			$ballCount="<tr class=\"td2\" id=\"maxDisBall0\"><th class=\"title02_3d\" style=\"text-justify:distribute-all-lines;\">{$chkPArrStr[$bettypegroup][0]}开出</th><td>".implode("</td><td>" , $ballDataArr[0][0])."</td></tr>";
			$disballCount="<tr class=\"td2\" id=\"maxDisBall\"><th class=\"title02_3d\" style=\"text-justify:distribute-all-lines;\">{$chkPArrStr[$bettypegroup][1]}开出</th><td>".implode("</td><td>" , $ballDataArr[0][1])."</td></tr>";
			unset($chkPArrStr);
			$maxTotal = max($ballDataArr[1]);
			$maxTotal0 = max($ballDataArr[0]);
			$starI = 1;
		}
		$jslink .= "<script>";
		$jslink .= "var chgBallArr = [0,0,0,0,0,0,0,0,0,0,0,0];";
		$jslink .= "var _maxTotal =".$maxTotal.";";
		$jslink .= "var _maxTotal0 =".$maxTotal0.";";
		$showChkPStr2="<span id=\"chgBV9\" class=\"disClc\">冠亚单双</span><span id=\"chgBV10\" class=\"disClc\">冠亚大小</span>";
		$i = $starI;
		for (; $i < 11; $i ++  )
		{
			$i2 = $i + 1;
			$cL = count($ballDataArr[$i2]);
			if ( 25 < $cL )
			{
				$ballDataArr[$i2] = array_slice($ballDataArr[$i2] , 0 - 25);
			}
			else if ( $cL < 25 )
			{
				$tempArr = array_fill($cL , 25 - $cL , "&nbsp;");
				$ballDataArr[$i2] = array_merge($ballDataArr[$i2] , $tempArr);
			}
			$jslink .= "chgBallArr[".$i."] = \"<td>".implode("</td><td>" , $ballDataArr[$i2])."</td>\";";
		}
		$jslink .= "</script>";
		unset($tempArr);
		unset($ballDataArr);
	}
	else
	{
		$jslink .= "<script> var chgBallArr = []; </script>";
	}
}
else
{
	$chkPArr = array ( "r1" => 0 , "rp1" => 1 , "rp2" => 2 , "rp3" => 3 , "rp4" => 4 , "rp5" => 5 , "rp6" => 6 , "rp7" => 7 , "rp8" => 8 , "rc" => 0 );
	$chkP = $chkPArr[$bettypegroup];
	$sql = "SELECT * FROM lotto_{$tbl} WHERE open = '".$open."' AND openbet < '".date("Y-m-d H:i:s")."' AND n1 > 0";
	$rs = getdb($sql);
	if ( ! $rs->eof )
	{
		$nidx = "n".$chkP;
		$pidx = "p".$chkP;
		$i = 0;
		$total = mysql_num_rows($rs->result);
		$ballDataArr = array (
			array ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) ,
			array ( $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total , $total ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( ) ,
			array ( )
		);
		$nTemp = array ( -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 );
		$a2Idx = array ( -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 );
		$pDataArr = array ( array ( 3 , 2 ) , array ( 4 , 1 ) , array ( 5 , 3 ) , array ( 6 , 4 ) , array ( 7 , 6 ) , array ( 8 , 5 ) );
		$pDataArr2 = array ( array ( 9 , 7 ) , array ( 10 , 8 ) , array ( 11 , 9 ) , array ( 12 , 18 ) );
		$pL = count($pDataArr);
		$pL2 = count($pDataArr2);
		$maxTotalArr = array ( );
		$maxTotal = 0;
		while ( ! $rs->eof )
		{
			if ( $chkP )
			{
				$ballNum = str_pad($rs->f[$nidx] , 2 , "0" , STR_PAD_LEFT);
				$ballNumIdx = $ballNum - 1;
				$ballDataArr[0][$ballNumIdx] ++;
				$j = 1;
				for (; $j < 9; $j ++  )
				{
					$ballNumIdxJ = $rs->f["n{$j}"] - 1;
					$ballDataArr[1][$ballNumIdxJ] = $total - $i - 1;
				}
				if ( $nTemp[2] != $ballNum )
				{
					$a2Idx[2] ++;
					$ballDataArr[2][$a2Idx[2]] = "";
				}
				$ballDataArr [2][$a2Idx[2]] .= $ballNum."<br />";
				$nTemp[2] = $ballNum;
				$pArr = str_split($rs->f[$pidx]);
				$j = 0;
				for (; $j < $pL; $j ++  )
				{
					$pIdx0 = $pDataArr[$j][0];
					$pIdx1 = $pDataArr[$j][1] - 1;
					if ( $nTemp[$pIdx0] != $pArr[$pIdx1] )
					{
						$a2Idx[$pIdx0] ++;
						$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] = "";
					}
					$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] .= ( $pArr[$pIdx1]?$RateConfig_5h->getBetContent($pDataArr[$j][1] , $pArr[$pIdx1] , TRUE):"和" )."<br />";
					$nTemp[$pIdx0] = $pArr[$pIdx1];
				}
			}
			$pArr = str_split($rs->f['p9']);
			for ( $j = 0; $j < $pL2; $j ++  )
			{
				$pIdx0 = $pDataArr2[$j][0];
				$pIdx1 = $j;
				if ( $nTemp[$pIdx0] != $pArr[$pIdx1] )
				{
					$a2Idx[$pIdx0] ++;
					$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] = "";
				}
				$ballDataArr[$pIdx0][$a2Idx[$pIdx0]] .= ( $pArr[$pIdx1]?$RateConfig_5h->getBetContent($pDataArr2[$j][1] , $pArr[$pIdx1] , TRUE):"和" )."<br />";
				$nTemp[$pIdx0] = $pArr[$pIdx1];
			}
			$i ++;
			$rs->next();
		}
		$maxTotal = 0;
		$maxTotal0 = 0;
		$starI = 8;
		if ( $chkP )
		{
			$ballTblTitle="<tr class=\"title02_3d color5h02\"><th>今天</th><th>01</th><th>02</th><th>03</th><th>04</th><th>05</th><th>06</th><th>07</th><th>08</th><th>09</th><th>10</th><th>11</th><th>12</th><th>13</th><th>14</th><th>15</th><th>16</th><th>17</th><th>18</th><th class=\"color5h01\">19</th><th class=\"color5h01\">20</th></tr>";
			$showChkPStr="<span id=\"chgBV1\" class=\"disClc\">".$RateConfig_5h->playtypeArr[$bettypegroup]."</span><span id=\"chgBV2\" class=\"disClc\">大小</span><span id=\"chgBV3\" class=\"disClc\">单双</span><span id=\"chgBV4\" class=\"disClc\">尾数大小</span><span id=\"chgBV5\" class=\"disClc\">合数单双</span><span id=\"chgBV6\" class=\"disClc\">方位</span><span id=\"chgBV7\" class=\"disClc\">中发白</span>";
			$ballCount="<tr class=\"td2\" id=\"maxDisBall0\"><th class=\"title02_3d\" style=\"text-justify:distribute-all-lines;\">出球率</th><td>".implode("</td><td>" , $ballDataArr[0])."</td></tr>";
			$disballCount="<tr class=\"td2\" id=\"maxDisBall\"><th class=\"title02_3d\" style=\"text-justify:distribute-all-lines;\">无出期数</th><td>".implode("</td><td>" , $ballDataArr[1])."</td></tr>";
			$maxTotal = max($ballDataArr[1]);
			$maxTotal0 = max($ballDataArr[0]);
			$starI = 1;
		}
		$showChkPStr2="<span id=\"chgBV8\" class=\"disClc\">总和单双</span><span id=\"chgBV9\" class=\"disClc\">总和大小</span><span id=\"chgBV10\" class=\"disClc\">总和尾数大小</span><span id=\"chgBV11\" class=\"disClc\">龙虎</span>";
		$jslink .= "<script>";
		$jslink .= "var chgBallArr = [0,0,0,0,0,0,0,0,0,0,0,0];";
		$jslink .= "var _maxTotal =".$maxTotal.";";
		$jslink .= "var _maxTotal0 =".$maxTotal0.";";
		$i = $starI;
		for (; $i < 12; $i ++  )
		{
			$i2 = $i + 1;
			$cL = count($ballDataArr[$i2]);
			if ( 25 < $cL )
			{
				$ballDataArr[$i2] = array_slice($ballDataArr[$i2] , 0 - 25);
			}
			else if ( $cL < 25 )
			{
				$tempArr = array_fill($cL , 25 - $cL , "&nbsp;");
				$ballDataArr[$i2] = array_merge($ballDataArr[$i2] , $tempArr);
			}
			$jslink .= "chgBallArr[".$i."] = \"<td>".implode("</td><td>" , $ballDataArr[$i2])."</td>\";";
		}
		$jslink .= "</script>";
	}
	else
	{
		$jslink .= "<script> var chgBallArr = []; </script>";
	}
}
echo $jslink;
?>
<table class="tblMy3D">     
<?php
echo $ballTblTitle.$ballCount.$disballCount;
?>
<tr class="td2"><th class="title02_3d" colspan="21" id="chgBallArea">
<?php
echo $showChkPStr.$showChkPStr2;
?></th></tr>
</table>
<table class="tblMy3D"><tr valign="top" id="chgBallAreaStr" class="td2"></tr></table>